package wangjg.mda.tra;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringEscapeUtils;

/**
 * 
 * @author wangjg
 *
 */
public class TemplateUtil {
	
	public boolean isNull(Object obj){
		return (obj == null);
	}
	
	public boolean isNotNull(Object obj){
		return (obj != null);
	}
	
	public boolean isList(Object obj){
		if(obj==null){
			return false;
		}
		return List.class.isInstance(obj);
	}
	
	public boolean isMap(Object obj){
		if(obj==null){
			return false;
		}
		return Map.class.isInstance(obj);
	}
	
	public static String getOmitted(String str, int size){
		if(str==null){
			return "";
		}
		if(str.length()<=size){
			return str;
		}
		String substr = str.substring(0, size-1)+"..";
		String html = StringEscapeUtils.escapeHtml(substr);
		return html;
	}

}
